<?php

class Blogmodel extends Model {

    var $title   = '';
    var $content = '';
    var $date    = '';
    
    function Blogmodel()
    {
        // Call the Model constructor
        parent::Model();
    }
   
    function get_last_ten_entries()
    {
        $query = $this->db->get('entries', 10);
        return $query->result();
    }

    function insert_entry()
    {
        $this->title   = $this->input->post('title');
        $this->content = $this->input->post('content');
        $this->date    = time();

        $this->db->insert('entries', $this);
    }

    function update_entry()
    {
        $this->title   = $this->input->post('title');
        $this->content = $this->input->post('content');
        $this->date    = time();

        $this->db->update('entries', $this, array('id' => $this->input->post('id')));
    }

}